﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="viewport" content="width=device-width,user-scalable=0"/>
    <meta charset="UTF-8">
    <title>BD健身</title>
    <script src="/api/js/fontSize.js"></script>
    <link rel="stylesheet" href="/api/css/bootstrap.min.css">
    <link rel="stylesheet" href="/api/css/reset.css">
    <link rel="stylesheet" href="/api/css/my_main.css">
     <script src="/assets/js/jquery.min.js"></script>
    <script src="/assets/layui.js"></script>
    <style>
        body{
            background: url("/api/images/login_back.jpg") no-repeat;
            background-size: cover;
            width: 100%;
            height: 100%;
            position: fixed;
        }
    </style>
</head>
<body>
<div class="login">

    <div class="login_cont">
        <div class="container">
            <div class="loginTitle">
                <div class="logo">
                    <img src="/api/images/logo.png">
                </div>
                <div class="title">
                    <img src="/api/images/bd_title.png">
                </div>
            </div>

            <div class="loginTab">

                <ul class="page">

                    <li>
                        <a href="" class="active">用户登录</a>

                    </li>

                    <li><a href="">商家登录</a></li>
                    <div class="sanjiao"></div>
                </ul>

                <div class="formLogin">


                    <form action="#" class="form-horizontal form_login">
                        <div class="form-group">
                            <input class="form-control" type="tel" id='tel' name="telphone" placeholder="手机号" required>
                        </div>
                        <div class="form-group number">

                            <input class="form-control" type="text" name="code" placeholder="验证码" required>
                            <a href="javascript:" id="getcode"><span>获取验证码</span></a>


                        </div>
                        <div class="form-group loginBtn">
                            <a href="javascript:"  id="login" class="btn btn-primary">
                                <span>登录</span>
                            </a>
                        </div>
                    </form>
                    <a href="/api/user/regis" class="reg pull-right">
                        <span>注册</span>
                    </a>
                    <div class="log-other">
                        <div class="pwd"><a href="/api/user/login"><span>密码登陆</span></a></div>

                        <div class="forget"><a href="/api/user/forgetPwd"><span>忘记密码</span></a></div>
                    </div>
                </div>



            </div>
        </div>

    </div>


</div>
<script type="text/javascript">

//手机验证码登录

$(function(){
	$('#login').click(function(){
		var data=$("form").serialize();
		var url='/api/user/Textlogin';
		//console.log(data);
		var layer;
		layui.use('layer', function(){
			   layer = layui.layer;
			}); 
		$.post(url,data,function(res){
			 
			var obj=eval('('+ res +')');
			var status=obj.status;
			var info=decodeURI(obj.info);
			if(obj.status==-1){
				layer.msg(info,{icon:5});
			}else if(status==400){
				
				layer.msg(info,{icon:5});
			}
		})
	});
	
	
$('#tel').blur(function(){
			var layer;
			layui.use('layer', function(){
				   layer = layui.layer;
				}); 
			that=$('#tel');
			var telphone=that.val();
			var url='/api/user/checkUserAccount';
			var data={telphone:telphone};
			$.get(url,data,function(res){
				var obj=sin(res);
				var status=obj.status;
				var info=obj.info;
				if(status==0){
					layer.msg(info,{icon:5},function(){
						window.location.href=obj.data;
					});
				}
				
			})
		});
	});
}else{
	layer.msg(info,{icon:6},function(){
		window.location.href=obj.data;
	})
};

	var  layer;
	layui.use('layer', function(){
		   layer = layui.layer;
});
	$('#getcode').click(function(){
		var url="/api/user/getTextValidateCode";
		var telphone=$('#tel').val();
		 
		if(telphone.length==0){
			
			layer.msg('请填写手机号',{icon:6});
		}
		if(telphone.length!=11){
			layer.msg('请填写正确的手机号格式',{icon:5});
		}
		var data={telphone:telphone};
		$.get(url,data,function(res){
		var obj=sin(res);
		var status=obj.status;
		var info=obj.info;
		if(status==400){
			layer.msg(obj.data.msg,{icon:5});
		}else if(status==200){
			layer.msg(info,{icon:6});
		}else {
			layer.msg(info,{icon:5});
		}
		
		})
		//$.get(url,)
	});
	function sin(res){
		return eval('('+ res +')');
	}
	
	
});



</script>

</body>

</html>